import os
import sys

def get_count(dr):
    count = 0
    for l in os.listdir(dr):
        p = dr +'/'+ l
        if os.path.isdir(p):
            count += get_count(p)
        if os.path.isfile(p):
            if l.endswith('.h') or l.endswith('.c') or l.endswith('.cpp'):
                print(p)
                lines = open(p,'r').readlines()
                tcount = 0
                for k in lines:
                    str_k = k.strip()
                    if str_k.find('/*') != 0 and str_k.find('//') !=0 and len(str_k) != 0 :
                        tcount +=1
                #t = len(open(p,'r').readlines())
                print(tcount)
                count += tcount
    return count

if __name__=="__main__":
    dr = sys.argv[1]
    t = get_count(dr)
    print(t)
